package press.xiang.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import press.xiang.entity.Commodity;
import press.xiang.entity.CommodityVO;

import java.util.List;

/**
 * 用户dao层
 * @description: TODO
 * @author xiang
 * @date 2022/4/21 6:33 下午
 * @version 1.0
 */
public interface CommodityMapper extends BaseMapper<Commodity> {

    @Update("truncate table tabu_commodity")
    void truncateCommodity();


    /**
     * @description: 获取仓库中的商品信息
     * @return: java.util.List<press.xiang.entity.CommodityVO>
     * @author xiang
     * @date: 2022/4/22 3:29 下午
     */
    @Select("SELECT " +
            "  s.name storeName, " +
            "  c.name, " +
            "  c.total, " +
            "  c.type " +
            "  FROM " +
            "  tabu_commodity c " +
            "  INNER JOIN tabu_store s ON c.store_id = s.id  ")
    List<CommodityVO> queryStoreByCommodity();


    @Select(" SELECT  " +
            " s.name storeName,count(s.name) commodityCount  " +
            " FROM  " +
            " tabu_commodity c  " +
            " INNER JOIN tabu_store s ON c.store_id = s.id   " +
            " GROUP BY storeName")
    List<CommodityVO> queryStoreByCount();


    @Select("select * from tabu_commodity where store_id = #{id}")
    List<Commodity> getCommodityByStore(String id);
}
